package com.fyzs.mp3recorder

import android.Manifest
import android.content.pm.PackageManager
import android.media.MediaRecorder
import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
import android.util.Log
import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment
import androidx.viewpager.widget.ViewPager
import androidx.viewpager2.widget.ViewPager2

class MainActivity : AppCompatActivity() {

lateinit var viewPager: ViewPager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        Log.i("build", "onCreate: ${Build.VERSION.SDK_INT}")
        viewPager = findViewById(R.id.view_pager)

        val pages = arrayListOf<Fragment>(
            MediaRecordFragment(),
            AudioRecorderFragment(),
            PickupFragment(),
            AnalyseFragment(),
        )
        viewPager.adapter = AudioPageAdapter(supportFragmentManager,pages)
        if(ActivityCompat.checkSelfPermission(this,Manifest.permission.RECORD_AUDIO)
        !=PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO,Manifest.permission.WRITE_EXTERNAL_STORAGE),0)
        }

    }
}